package me.shiqiang.im.config;

import com.aliyun.openservices.ons.api.PropertyKeyConst;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author cuishiqiang
 * @date 2017/12/6 下午9:16
 */
@ConfigurationProperties(prefix="com.tst.rocketmq.producer")
@Configuration
public class RocketMqProducerConfig {
    private String accessKey;
    private String secretKey;
    private String addr;
    private String producerId;

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public String getProducerId() {
        return producerId;
    }

    public void setProducerId(String producerId) {
        this.producerId = producerId;
    }

    public Properties getProperties(){
        Properties consumerProperties = new Properties();
        consumerProperties.setProperty(PropertyKeyConst.ProducerId, getProducerId());
        consumerProperties.setProperty(PropertyKeyConst.AccessKey, getAccessKey());
        consumerProperties.setProperty(PropertyKeyConst.SecretKey, this.getSecretKey());
        consumerProperties.setProperty(PropertyKeyConst.ONSAddr, this.getAddr());
        return consumerProperties;
    }
}
